﻿<%@ Page Language="C#" MasterPageFile="~/Templates/top.master" AutoEventWireup="true" CodeFile="Cart-selAdd.aspx.cs" Inherits="Cart_selAdd" Title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
 
    <div id="cart-index" class="CartWrap"> 
        <table width="100%">
            <tr style="height:80px;"><td valign="top" style="background-color:#ffffff;"><img alt="购物流程--查看购物车" src="img/themes/cartnav-step3.gif" /></td><td valign="top" style="background-color:#ffffff;"><img src="img/themes/cartnav-cart.gif" /></td></tr>
        </table>
        
        <div id="cart-items" class="section">
            
            <div style="padding:0px; background-color:#fff; width:100%;">                
                <div  style="margin-left:5px; margin-right:5px;" id="cart-address">
                确认收货地址 &nbsp; &nbsp; <a href="Member-Address.aspx" class="managerAdd" target="_blank">管理收货地址</a>
                <hr />
                <table id="tblAddress" style="margin:20px 20px 10px 30px; width:95%;">
                    <asp:Repeater ID="rtpAdd" runat="server">
                        <ItemTemplate>
                        <tr class="<%# Eval("isDefault").ToString()=="1"?"trAddressDefault":"trAddress" %> ">
                            <td > 
                                <input value="<%# Eval("addressID") %>" onclick="changeAddress(this,0)" type="radio" name="radioAddress"  <%# Eval("isDefault").ToString()=="1"?"checked":"" %> add=" <%# Eval("province")%> <%# Eval("city")%>  <%# Eval("area")%>  <%# Eval("address")%> " consi="<%# Eval("consignee")%>" phone=" <%# Eval("phone")%> <%# Eval("phone1")%>" postcode="<%# Eval("postCode")%>" > 
                                <%# Eval("province")%> <%# Eval("city")%>  <%# Eval("area")%>  <%# Eval("address")%> ( <%# Eval("consignee")%> 收) <%# Eval("phone")%> <%# Eval("phone1")%> 
                            </td>
                            <td style="color:#666666; font-size:12px; width:120px" align="center"><%# Eval("isDefault").ToString()=="1"?"默认地址":"" %></td>
                        </tr>
                        </ItemTemplate>
                    </asp:Repeater>
                    <tr class="trAddress">
                        <td><input type="radio" id="radioAddress" name="radioAddress" value="0"  onclick="changeAddress(this,1)" /> 使用新地址
                            <div id="divNewAddress"  style=" margin-left:20px; display:none; "   > 
                                  <table cellpadding="0" cellspacing="0" border="0">
                                    
                                    <tr style="height:25px;"><td align="right">收货人姓名：</td><td>
                                        <asp:TextBox ID="txtName"    runat="server" MaxLength="16"></asp:TextBox></td>
                                        <td></td>   
                                    </tr>  
                                    <tr style="height:25px;"><td align="right">所在地区：</td><td>
                                            <select style="width:70px;" id="SelectPro" onchange="ProvinceChange(this,SelectCity);"></select>
                                        <select style="width:90px;" id="SelectCity" onchange="CityChange(this,SelectArea)"></select>
                                        <select style="width:90px;" id="SelectArea" ></select>
                                            </td>
                                        <td></td>
                                    </tr>
                                    <tr style="height:25px;"><td align="right">街道地址：</td><td>
                                            <asp:TextBox ID="txtAddress"  runat="server" Width="429px" Height="50px" TextMode="MultiLine"></asp:TextBox></td>
                                        <td> &nbsp; 不需要重复填写省/市/区</td> 
                                    </tr>
                                    <tr style="height:25px;"><td align="right">邮政编码：</td><td>
                                        <asp:TextBox ID="txtPostCode" runat="server" MaxLength="6"></asp:TextBox></td>
                                        <td></td>   
                                    </tr>  
                                    <tr style="height:25px;"><td align="right">电话号码：</td><td>
                                        <asp:TextBox ID="txtPhone" runat="server" MaxLength="32"></asp:TextBox></td>
                                        <td></td>   
                                    </tr>  
                                    <tr style="height:25px;"><td align="right">手机号码：</td><td>
                                        <asp:TextBox ID="txtPhone1" runat="server" MaxLength="15"></asp:TextBox></td>
                                        <td></td>   
                                    </tr>  
                                 </table><br />
                            </div>
                        </td>
                        <td>&nbsp;</td>
                    </tr>
                </table>
                
                <br /> 
                确认订单情况
                          
                </div>
             
            </div>
     
            
            <div id="cartItems" class="FormWrap" style="padding:7px;">
 
                <div id="goodsbody" class="division">
                    <table id="tblCarts" class="liststyle" width="100%"  cellspacing="0" cellpadding="1">
                        <tr class="tableHeader">
                            
                            <td style="width: 80px">
                                图片</td>
                            <td>
                                商品名称</td>
                            <td style="width: 50px">
                                尺码</td>    
                            <td style="width: 50px">
                                颜色</td>     
                            <td style="width: 80px">
                                销售价格</td>
                            <td style="width: 80px">
                                优惠价格</td>
                            <td style="width: 80px">
                                数量</td>
                            <td style="width: 80px">
                                小计</td> 
                        </tr> 
                        <%= strConent%>
 
                    </table>
                    
                    <table style="width:100%;">
 
                        <tr>
                            <td align="right" style="font-size: 14px; color: #000;">
                                商品总额： 
                            </td>
                            <td class="totalprice price1" style=" width:150px;" align="left">
                                <div id="totalPrice">￥<asp:Label ID="lblTtotal" runat="server" Text="Label"></asp:Label></div>                                
                            </td>
                        </tr> 
                </table>
 
                </div>
            </div>
            <div class="CartBtn clearfix" style="margin-bottom: 5px;width:100%;">
                <div class="span-auto">
                    <a class="actbtn btn-return" href="./">«继续购物</a>
                </div>
                <div class="span-auto">
                    <a id="clearCart" class="actbtn btn-catrtn" href="javascript:window.history.go(-1);">
                        返回</a>
                </div>
                <div class="span-auto floatRight">                     
                    <asp:Button ID="btnSubmit" OnClientClick="return CheckForm();" CssClass="actbtn btn-next"  runat="server" Text="" OnClick="btnSubmit_Click" />                      
                    
                </div>
            </div>
        </div>
        <div style="position: absolute; z-index: 500; visibility: hidden; opacity: 0; border: 1px solid rgb(102, 102, 102);
            left: 250px; top: -38px;">
            <img src="http://www.umishop.com.cn/images/goods/20121030/236a5605c8b854e7.jpg" style="cursor: pointer;
                border: 1px solid rgb(255, 255, 255);" />
        </div>

    </div> 
     <div style="display:none;">
        <asp:TextBox ID="txtProvince" runat="server"></asp:TextBox>
        <asp:TextBox ID="txtCity" runat="server"></asp:TextBox>
        <asp:TextBox ID="txtArea" runat="server"></asp:TextBox>
          
         <asp:TextBox  ID="txtDeliverAddress" runat="server"></asp:TextBox>
         <asp:TextBox  ID="txtDeliverPhone" runat="server"></asp:TextBox>
         <asp:TextBox  ID="txtDeliverName" runat="server"></asp:TextBox>
         <asp:TextBox  ID="txtDeiverPostCode" runat="server"></asp:TextBox>
         <asp:TextBox ID="txtAddNew" Text="0" runat="server"></asp:TextBox>
    </div>
 <script type="text/javascript" language="javascript" src="js/Area.js"></script>
<script type="text/javascript" language="javascript">
window.onload=function()
{
    DataBing(document.getElementById("SelectPro"),ArrProvince); 
    var val = 0;
    var objs = document.getElementsByName("radioAddress");
    for(var i=0;i<objs.length;i++)
    { 
        if(objs[i].checked)
        {
            objChk=objs[i];
            val = objs[i].value;           
            
            break;
         }
    } 
    if( val=="0")
    {
        var radio = document.getElementById("radioAddress");
        radio.checked=true;
        changeAddress(radio,1)
    }
 
}
function CheckForm()
{

    var val = 0;
    var objs = document.getElementsByName("radioAddress");
    var objChk;
    var add = document.getElementById("ctl00_ContentPlaceHolder1_txtDeliverAddress");
    var phone = document.getElementById("ctl00_ContentPlaceHolder1_txtDeliverPhone");
    var consineer = document.getElementById("ctl00_ContentPlaceHolder1_txtDeliverName");
    var postcode = document.getElementById("ctl00_ContentPlaceHolder1_txtDeiverPostCode");
    var addNew = document.getElementById("ctl00_ContentPlaceHolder1_txtAddNew");
    for(var i=0;i<objs.length;i++)
    { 
        if(objs[i].checked)
        {
            objChk=objs[i];
            val = objs[i].value;           
            
            break;
         }
    } 
    if( val=="0")
    {
        var strName =trim(document.getElementById("ctl00_ContentPlaceHolder1_txtName").value);
        if(strName=="")
        {
            alert("收货人姓名不能为空！");
            document.getElementById("ctl00_ContentPlaceHolder1_txtName").focus();
            return false;
        }
        var strProvince = document.getElementById("SelectPro").value;;
        if(strProvince == "")
        {
            alert("请选择一个省份！");
            document.getElementById("SelectPro").focus();
            return false;
        }
        var strCity = document.getElementById("SelectCity").value;;
        if(strCity == "")
        {
            alert("请选择一个城市！");
            document.getElementById("SelectCity").focus();
            return false;
        }
        var strArea = document.getElementById("SelectArea").value;;
//        if(strArea == "")
//        {
//            alert("请选择一个县区！");
//            document.getElementById("SelectArea").focus();
//            return false;
//        }
        
        var strAdd = trim(document.getElementById("ctl00_ContentPlaceHolder1_txtAddress").value);
        if(strAdd == "")
        {
            alert("街道地址不能为空 ！");
            document.getElementById("ctl00_ContentPlaceHolder1_txtAddress").focus();
            return false;
        }
        var strPhone =  trim(document.getElementById("ctl00_ContentPlaceHolder1_txtPhone").value);
        var strPhone1 = trim(document.getElementById("ctl00_ContentPlaceHolder1_txtPhone1").value);
        if(strPhone=="" && strPhone1=="")
        {
            alert("电话或者手机必须要填写一项！");
            document.getElementById("ctl00_ContentPlaceHolder1_txtPhone").focus();
            return false;
        }
        var objPro =  document.getElementById("SelectPro");
        var objCity = document.getElementById("SelectCity");
        var objArea = document.getElementById("SelectArea");
        document.getElementById("ctl00_ContentPlaceHolder1_txtProvince").value =objPro.options[objPro.selectedIndex].text;
        document.getElementById("ctl00_ContentPlaceHolder1_txtCity").value = objCity.options[objCity.selectedIndex].text;
        document.getElementById("ctl00_ContentPlaceHolder1_txtArea").value = objArea.options[objArea.selectedIndex].text;
        add.value="";
        phone.value="";
        consineer.value= "";
        postcode.value="";
        addNew.value = "1";
    }
    else
    {
        add.value=objChk.getAttribute("add");
        phone.value = objChk.getAttribute("phone");
        consineer.value = objChk.getAttribute("consi");
        postcode.value = objChk.getAttribute("postcode");
        addNew.value="0";
    }
    
    

    return true;
} 
 function changeAddress(obj,isNew)
 {
    var tbl = document.getElementById("tblAddress");
    var rows = tbl.rows;
    for(var i=0;i<rows.length;i++)
    {
        rows[i].className="trAddress";
    }
    var divNewAddress = document.getElementById("divNewAddress");
    if(isNew == "1")
    {
        obj.parentNode.parentNode.className="trAddressNew";
        divNewAddress.style.display = "block";
    }
    else
    {
         obj.parentNode.parentNode.className="trAddressDefault";
         divNewAddress.style.display = "none";
    }
    
    
 }
 
 </script>  
</asp:Content>

